package org.common.utils.config;

import org.common.utils.nacos.entity.NacosConfigAddress;

import java.util.ArrayList;
import java.util.List;

/**
 * 配置
 * @author zhouzhibing
 * @date 2025/6/14
 */
public class ConfigInfo {

    /**
     * 配置文件路径
     */
    private String filePath;

    /**
     * resource文件类型
     */
    private String resource;

    /**
     * nacos 配置地址列表
     */
    private List<NacosConfigAddress> nacosConfigAddress = new ArrayList<>();

    private ConfigInfo() {

    }

    public String getFilePath() {
        return filePath;
    }

    public String getResource() {
        return resource;
    }

    public List<NacosConfigAddress> getNacosConfigAddress() {
        return nacosConfigAddress;
    }

    @Override
    public String toString() {
        return "ConfigInfo{" +
                "filePath='" + filePath + '\'' +
                ", resource='" + resource + '\'' +
                ", nacosConfigAddress=" + nacosConfigAddress +
                '}';
    }

    public static Builder newBuilder() {
        return new Builder();
    }

    public static class Builder {

        private final ConfigInfo configInfo = new ConfigInfo();

        /**
         * 文件路径
         * @param path 路径
         * @return Builder
         */
        public Builder setFilePath(String path) {
            configInfo.filePath = path;
            return this;
        }

        /**
         * 配置文件路径
         * @param resource 资源路径
         * @return Builder
         */
        public Builder setResource(String resource) {
            configInfo.resource = resource;
            return this;
        }

        /**
         * nacos 配置
         * @param nacosConfigAddress nacos 配置
         * @return Builder
         */
        public Builder addNacosConfigAddress(NacosConfigAddress nacosConfigAddress) {
            configInfo.nacosConfigAddress.add(nacosConfigAddress);
            return this;
        }

        public ConfigInfo build() {
            return configInfo;
        }
    }

}
